var datatable;// 定义一个全局的dataTable

function getList(){
	var dateType=$("#dateType").val();
	var beginDate=$("#beginDate").val();
	var endDate=$("#endDate").val();
	var interfaceType=$("#interfaceType").val();
	var procedureType=$("#procedureType").val();
	var failureType=$("#failureType").val();
	var failureDetailQueryCond = $("#failureDetailQueryCond").val();
	$("#table tbody tr").remove();
	if (datatable == undefined || datatable == "undefined" || datatable == null) {
	} else {
		datatable.fnDestroy();
	}
	datatable = $('#table').dataTable({
		"aoColumnDefs" : [ {
	        sDefaultContent : '',
	        aTargets : [ '_all' ]
	    } ],
		"bPaginate" : true, // 翻页功能
		"bLengthChange" : false, // 改变每页显示数据数量
		"bFilter" : false, // 过滤功能
		"bSort" : false, // 排序功能
		"bInfo" : true,// 页脚信息
		"bAutoWidth" : true,// 自动宽度
		 "fnDrawCallback": function (oSettings) {
			 },
		 "fnCreatedRow": function( nRow, aData, iDataIndex ) {
//				 var currentPage=$(".current").text();
//				 alert("currentPage"+currentPage);
//				 if(null==currentPage || currentPage==undefined || currentPage=="undefined" || currentPage=="")
//					 currentPage=1;
//				 var pageSize=$("select[name=table_length]").val();
//				 var start=(currentPage-1)*pageSize+iDataIndex+1;
//				 alert(start);
		    },	 
		// "sPaginationType": "full_numbers",//显示分页的样式 还有simple_numbers等
		"sScrollX" : "100%",
		"sScrollXInner": "110%",
		"iDisplayLength" : 50,
		"bScrollCollapse" : true,
		"oLanguage" : {
			"sLengthMenu" : "每页显示 _MENU_条",
			"sZeroRecords" : "没有找到符合条件的数据",
			"sProcessing" : "&nbsp;&nbsp;&nbsp;&nbsp;查询中，请稍等...",
			"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
			"sInfoEmpty" : "没有记录",
			"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
			"sSearch" : "搜索：",
			"oPaginate" : {
				"sFirst" : "首页",
				"sPrevious" : "前一页",
				"sNext" : "后一页",
				"sLast" : "尾页"
			}
		},
		"bProcessing" : true,
		"bServerSide" : true,
		"sAjaxSource" : "../../kpi/failureDetail/getDetailList",
		"fnServerData" : function(sSource, aoData, fnCallback) {
			$.ajax({
				"type" : "post",
				"contentType" : "application/x-www-form-urlencoded",
				"url" : sSource,
				"dataType" : "json",
				"data" : {
					"aoData" : JSON.stringify(aoData),
					"dateType":dateType,
					"interfaceType" : interfaceType,
					"beginDate" : beginDate,
					"endDate" : endDate,
					"procedureType" : procedureType,
					"failureType" : failureType,
					"failureTypeInfo" : $("#failureTypeInfo").val(),
					"jspType" : $("#jspType").val(),
					"queryCond" : $("#queryCond").val(),
					"failureDetailQueryCond" : $("#failureDetailQueryCond").val(),
					"imsi" : $("#imsi").val(),
					"city_code" : $("#city_code").val(),
					"enodeb_id" : $("#enodeb_id").val(),
					"cell_name" : $("#cell_name").val(),
					"keyword" : $("#keyword").val(),
					"terminal_model" : $("#terminal_model").val(),
					"terminal_brand" : $("#terminal_brand").val(),
					"msisdn" : $("#msisdn").val(),
					"apn" : $("#apn").val()
				}, // 以json格式传递
				"success" : function(resp) {
					var status=resp.status;
					if(status!="0"){
						alert(resp.msg);
					}
					fnCallback(resp.pageDate);
				}
			});
		},
		columns : [ {
			data : "start_date"
		}, {
			data : "city_name"
		}, {
			data : "imsi"
		}, {
			data : "imei_sv"
		}, {
			data : "user_ipv4"
		}, {
			data : "msisdn"
		}, {
			data : "tai"
		}, {
			data : "ci"
		}, {
			data : "apn"
		}, {
			data : "cause"
		}, {
			data : "",
			render:function(value,type,full){
				return "<a href='#' onclick=\"toSignalBack('"+full.start_date+"','"+full.imsi+"','"+full.msisdn+"')\"  >信令回溯</a>";
			}
		}, {
			data : "enodeb_id"
		}, {
			data : "enodeb_name"
		}, {
			data : "cellname"
			}]

		});
 
	}
function test(){
	alert(0);
	$("#table thead").hide();
}
function failureCountDetail(failureType){
	var dateVal=$('input[name="dateType"]:checked ').val();
	var beginDate;
	var endDate;
	if(dateVal=="custom"){
		beginDate=beginDateTemp;
		endDate=endDateTemp;
	}else{
		beginDate=$("#beginDate").val().trim();
		endDate=$("#endDate").val().trim();
	}
	var interfaceVal=$("#sel_interface").val();
	var procedureType=$("#sel_signal").val();
//	param.put("dateType", request.getParameter("dateType"));
//	param.put("beginDate", request.getParameter("beginDate"));
//	param.put("endDate", request.getParameter("endDate"));
//	param.put("interfaceType", request.getParameter("interfaceType"));
//	param.put("procedureType", request.getParameter("procedureType"));
//	param.put("failure_type", request.getParameter("failure_type"));
	var url="/kpi/failureDetail/index?"+"&dateType="+dateVal+"&beginDate="+beginDate+"&endDate="+endDate+"&interfaceType="+interfaceVal+"&procedureType="+procedureType+"&failureType="+failureType;
	linkTab("故障详单",url);
//	alert(url);
//	alert("待跳转到故障详单页面");
	window.location.href=url;
}
function toSignalBack(start_date,imsi,msisdn){
	var url="/kpi/signalBackTrack/index?phoneNumber="+msisdn.trim()+"&imsi="+imsi.trim()+"&beginDate="+start_date.trim()+"&endDate="+start_date.trim();
	linkTab("信令回溯",url);
}